import request from '@/router/axios';

/**
 * 获取列表
 * @param current
 * @param size
 * @param params
 * @returns {*}
 */
export const getReceivableList = (current, size, params) =>{
  return request({
    url: '/api/beetles-business/finance/receivable/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

/**
 * 新增/修改
 * @param data
 * @returns {*}
 */
export const addReceivable = (financeReceivable, accountCostDetails) =>{
  return request({
    url:'/api/beetles-business/finance/receivable/save',
    method:'post',
    data: {
      financeReceivable: financeReceivable,
      accountCostDetails: accountCostDetails
    }
  })
}

export const addProgress = (id, content) =>{
  debugger
  var progress = {"receivableId":id, "content":content}
  return request({
    url:'/api/beetles-business/finance/receivable/save_progress',
    method:'post',
    timeout: 3600 * 1000,
    data: progress
  })
}

export const getProgressList = (receivableId) =>{
  return request({
    url: '/api/beetles-business/finance/receivable/get_progress_list',
    method: "get",
    params: {
      receivableId
    }
  })
}

/**
 * 删除
 * @param data
 * @returns {*}
 */
export const removeReceivable = (data) =>{
  return request({
    url:'/api/beetles-business/finance/receivable/remove',
    method:'post',
    params:{
      ids:data
    }
  })
}

/**
 * 更新
 * @param data
 * @returns {*}
 */
export const updateReceivable = (financeReceivable, accountCostDetails) =>{
  return request({
    url:'/api/beetles-business/finance/receivable/update',
    method:'post',
    data: {
      financeReceivable: financeReceivable,
      accountCostDetails: accountCostDetails
    }
  })
}


export const changeReceivableStatus = data =>{
  return request({
    url: '/api/beetles-business/finance/receivable/changeStatus',
    method: "post",
    data:{...data}

  })
}

export const getReceivableCustomers = () =>{
  return request({
    url: '/api/beetles-business/finance/receivable/receivable-customer',
    method: "get",
  })
}

export const getInvoiceMakers = () =>{
  return request({
    url: '/api/beetles-business/finance/receivable/invoice_makers',
    method: "get",
  })
}

export const getEntityList = (current, size) =>{
  return request({
    url: '/api/beetles-business/finance/invoiceEntity/page',
    // url: '/api/beetles-business/finance/invoiceEntity/entityPage',
    method: 'get',
    params: {

      current,
      size,
    }
  })
}

export const downloadInvoice = (id, fileType, badge) => {
  return request({
    url: '/api/beetles-business/finance/receivable/exportInvoice',
    method: "get",
    params:{id, fileType, badge},
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    // responseType: 'blob'
  })
}

export const exportExcel3 = (ids) => {
  return request({
    url: '/api/beetles-business/finance/receivable/export',
    method: "get",
    params:ids,
    responseType: 'blob',
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    // responseType: 'blob'
  })
}

export const getFinanceEntityList = (customerId) => {
  return request({
    url: '/api/beetles-business/finance/invoiceEntity/list',
    method: 'get',
    params: {
      customerId
    }
  })
}
//批量修改状态
export const batchChangeStatus = data => {
  return request({
    url: '/api/beetles-business/finance/receivable/batchChangeStatus',
    method: 'post',
    data:data
  })
}

//是否财务角色
export const isFinanceRole = () => {
  return request({
    url: '/api/beetles-business/finance/receivable/is-finance-role',
    method: 'get',
  })
}

export const getAppSelectbyCostomer = params => {
  return request({
    url: '/api/beetles-business/app/get-app-select-by-customer',
    method: 'get',
    params
  })
}

export const getAccountCostDetails = params => {
  return request({
    url: '/api/beetles-business/finance/receivable/get_account_cost_details',
    method: 'get',
    params
  })
}
